/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_UNIDADE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Unidade.findAll", query = "SELECT u FROM Unidade u"),
    @NamedQuery(name = "Unidade.findByUndId", query = "SELECT u FROM Unidade u WHERE u.undId = :undId"),
    @NamedQuery(name = "Unidade.findByUndIg", query = "SELECT u FROM Unidade u WHERE u.undIg = :undIg"),
    @NamedQuery(name = "Unidade.findByUndDs", query = "SELECT u FROM Unidade u WHERE u.undDs = :undDs")})
public class Unidade implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "UND_ID")
    private BigDecimal undId;
    @Size(max = 104)
    @Column(name = "UND_IG")
    private String undIg;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 259)
    @Column(name = "UND_DS")
    private String undDs;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "oguUndId")
    private List<OrgaoUnidade> orgaoUnidadeList;

    public Unidade() {
    }

    public Unidade(BigDecimal undId) {
        this.undId = undId;
    }

    public Unidade(BigDecimal undId, String undDs) {
        this.undId = undId;
        this.undDs = undDs;
    }

    public BigDecimal getUndId() {
        return undId;
    }

    public void setUndId(BigDecimal undId) {
        this.undId = undId;
    }

    public String getUndIg() {
        return undIg;
    }

    public void setUndIg(String undIg) {
        this.undIg = undIg;
    }

    public String getUndDs() {
        return undDs;
    }

    public void setUndDs(String undDs) {
        this.undDs = undDs;
    }

    @XmlTransient
    public List<OrgaoUnidade> getOrgaoUnidadeList() {
        return orgaoUnidadeList;
    }

    public void setOrgaoUnidadeList(List<OrgaoUnidade> orgaoUnidadeList) {
        this.orgaoUnidadeList = orgaoUnidadeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (undId != null ? undId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Unidade)) {
            return false;
        }
        Unidade other = (Unidade) object;
        if ((this.undId == null && other.undId != null) || (this.undId != null && !this.undId.equals(other.undId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.ana.service.Unidade[ undId=" + undId + " ]";
    }
    
}
